﻿@model ProductDetailsModel.ProductVariantModel.AddToCartModel
@using Nop.Web.Models.Catalog;
@using Nop.Core.Domain.Orders;
<div class="add-to-cart col-sm-12 col-md-12 col-lg-8">
    @if (Model.CustomerEntersPrice)
    {
        <div class="customer-entered-price">


            @Html.TextBox("CustomerEnteredPrice", Convert.ToInt32(Math.Ceiling(Model.CustomerEnteredPrice)), new { @class = "enter-price-input" })
            <div class="price-range">
                @Model.CustomerEnteredPriceRange
            </div>


        </div>
    }
    @if (!Model.DisableBuyButton || !Model.DisableWishlistButton)
    {
        <div class="quantity-container">
            <div class="row">
                <div class="col-xs-2 col-md-1">
                    @Html.LabelFor(model => model.EnteredQuantity, new { @class = "qty-label" })
                </div>
                <div class="col-xs-10 col-md-7">

                    @if (Model.AllowedQuantities.Count > 0)
                    {
                        @Html.DropDownListFor(model => model.EnteredQuantity, Model.AllowedQuantities, new { @class = "qty-dropdown" })
                    }
                    else
                    {
                        <input type="number" min="0" class="qty-input qty-input-@Model.ProductVariantId form-control" name="@Html.NameFor(model => model.EnteredQuantity)" value="@Html.ValueFor(model => model.EnteredQuantity)">
                        <script>
                            $(".qty-input-@Model.ProductVariantId").keypress(function (e) {
                                var keycode = (e.keyCode ? e.keyCode : e.which);
                                if (keycode == '13') {
                                    AjaxCart.addproductvarianttocart('@Url.RouteUrl("AddProductVariantToCart", new { productVariantId = Model.ProductVariantId, shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart })', $(this).closest('form'), $(this).closest(".quantity-container").find("a.add-to-cart"));
                                    $(this).blur();
                                    e.stopPropagation();
                                    e.preventDefault();
                                }
                            });
                        </script>
                    }
                </div>
                @if (!Model.DisableBuyButton && !Model.AvailableForPreOrder)
                {
                    <div class="col-md-4">
                        <a class="btn btn-danger form-control add-to-cart" href="javascript:void(0)" onclick="AjaxCart.addproductvarianttocart('@Url.RouteUrl("AddProductVariantToCart", new { productVariantId = Model.ProductVariantId, shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart })', $(this).closest('form'), $(this));return false;"><span>@(T("ShoppingCart.AddToCart"))</span></a>
                        <div class="product-add-loading">
                            <img class="loading-gif" src="/content/images/loading.gif" />
                            <img class="loading-svg" src="/content/images/loading.svg" />
                        </div>
                        @if (Model.AllowDirectCheckout)
                        {
                            <a class="btn btn-primary" onclick="AjaxCart.addproductvarianttocart('@Url.RouteUrl("AddProductVariantToCart", new { productVariantId = Model.ProductVariantId, shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart })', $(this).closest('form'), $(this), true);return false;">Checkout Directly</a>
                            <div class="modal fade" id="direct-checkout" tabindex="-1" role="dialog">

                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                            <h4 class="modal-title" id="exampleModalLabel">Direct Checkout</h4>
                                        </div>
                                        <div class="modal-body">

                                        </div>
                                    </div>
                                </div>

                            </div>
                        }
                    </div>
                    @*<div class=" product-loading">
                            <img class="loading-svg" src="~/Content/Images/loading.svg" />
                            <img class="loading-gif" src="~/Content/Images/loading.gif" />
                            <div>@T("Common.Loading")</div>
                        </div>*@
                }

            </div>
        </div>
        @*<div class="col-ms-6 col-xs-6 col-sm-6 col-md-6 col-lg-4">
                @if (!Model.DisableWishlistButton)
                {
                    <a class="button-grey wishlist-button" href="javascript:void(0)" onclick="AjaxCart.addproductvarianttocart('@Url.RouteUrl("AddProductVariantToCart", new { productVariantId = Model.ProductVariantId, shoppingCartTypeId = (int)ShoppingCartType.Wishlist })', $('#product-details-form'), $(this));return false;"><i class="fa fa-asterisk"></i>&nbsp;&nbsp;<span>@T("ShoppingCart.AddToWishlist")</span></a>
                }
            </div>*@

    }
    @if (Model.DisableBuyButton)
    {
        <div clas="col-md-4"><label style="color:red;font-weight:300 bold">@T("orderdetial.ifDisableButton")</label></div>
    }
    @if (Model.AvailabldForReserve)
    {
        <div class="add-item">
            <a class="btn btn-primary" onclick="AjaxCart.reserveproductvariant('@Url.RouteUrl("ReserveProductVariant", new { productVariantId = Model.ProductVariantId,storeId = Model.StoreId })', $(this).closest('form'), $(this));return false;">Reserve Product</a>
            <div class="modal fade" id="direct-checkout" tabindex="-1" role="dialog">

                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="exampleModalLabel">Reserve Product</h4>
                        </div>
                        <div class="modal-body">

                        </div>
                    </div>
                </div>

            </div>
        </div>
    }
    @Html.Widget("productdetails_add_info")
    <div class="clear"></div>
</div>
